﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;

namespace Helpers
{
    public class AutoMapperHelper
    {
        public static T2 To<T1, T2>(T1 t1)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap<T1, T2>());
            var mapper = config.CreateMapper();
            return mapper.Map<T1, T2>(t1);
        }

        public static T Copy<T>(T t1)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap<T, T>());
            var mapper = config.CreateMapper();
            return mapper.Map<T, T>(t1);
        }
    }
}
